// pages/index/psychology/knowlege/knowlege.js
Page({

  /**
   * Page initial data
   */
  data: {
    knowlegeData: [],
    pageNo:1,
    pageSize:7,
    isLoading: false,
    hasMore: true,
  },
getNet(){
   wx.request({
          url: `http://localhost:8080/knowledge/getKnowledgesPage?pageNo=${this.data.pageNo}&pageSize=${this.data.pageSize}`,
          success: (res) => {
            this.setData({
                knowlegeData: res.data.data,
            })
            console.log(res.data.data);
            console.log(this.data.knowlegeData);
          }
        });
},
  /**
   * Lifecycle function--Called when page load
   */
  onLoad(options) {
     this.getNet();
  },

  /**
   * Lifecycle function--Called when page is initially rendered
   */
  onReady() {

  },

  /**
   * Lifecycle function--Called when page show
   */
  onShow() {

  },

  /**
   * Lifecycle function--Called when page hide
   */
  onHide() {

  },

  /**
   * Lifecycle function--Called when page unload
   */
  onUnload() {

  },

  /**
   * Page event handler function--Called when user drop down
   */
  onPullDownRefresh() {

  },

  /**
   * Called when page reach bottom
   */
  onReachBottom() {
    setTimeout(() => {
      let i = this.data.pageNo + 1;
      this.setData({
        pageNo: i
      })
      let that = this;
      wx.request({
        url: `http://localhost:8080/knowledge/getKnowledges?pageNo=${this.data.pageNo}&pageSize=${this.data.pageSize}`,
        success: (res) => {
          console.log(res);
          that.setData({
            knowlegeData: [...that.data.knowlegeData, ...res.data.data]
          })
        }
      })
    }, 1000);
  },

  /**
   * Called when user click on the top right corner to share
   */
  onShareAppMessage() {

  }
})